/**************************************************************************************
* TextPanel.java
* 
*************************************************************************************/
package creid.mythos.ui;

import java.awt.Graphics;

public class TextPanel extends GamePanel
{
	private static final long serialVersionUID = 6139214429730650561L;

	//Constants/////////////////////////////////////////////////////////////////////////

	//Attributes////////////////////////////////////////////////////////////////////////
	
	private String[] text;

	//Constructors//////////////////////////////////////////////////////////////////////
	
	public TextPanel()
	{
		text = null;
	}

	//Methods///////////////////////////////////////////////////////////////////////////
	
	void setText(String[] text)
	{
		this.text = text;
	}
	
	void clearText()
	{
		this.text = null;
	}
	
	@Override
	public void paintComponent(Graphics g)
	{
		super.paintComponent(g);
		
		if (text != null)
		{
			int x = GameUI.FONT_HORIZONTAL_SPACING;
			int y = GameUI.FONT_VERTICAL_SPACING;
			
			for (String line: text)
			{
				g.drawChars(line.toCharArray(), 0, line.length(), x, y);
				y += GameUI.FONT_VERTICAL_SPACING;
			}
		}
	}
}
